package com.nexgo.payment.scan;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.nexgo.payment.R;
import com.nexgo.payment.ui.BaseFragment;
import com.nexgo.payment.widget.TitleBuilder;


/**
 * 扫码界面
 *
 * Created by wanghongyang on 2017/9/1.
 */
public class ScanNFragment extends BaseFragment {


    public ScanNFragment() {
    }

    public static ScanNFragment newInstance() {
        ScanNFragment fragment = new ScanNFragment();
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //强制屏幕常亮
        Window win = getActivity().getWindow();
        win.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//        //屏蔽菜单键
        win.addFlags(5);
//        //屏蔽home键
        win.addFlags(3);
        //屏蔽下拉
//        Settings.System.putInt(getContext().getContentResolver(), "status_bar_disabled", 1);

    }

    @Override
    protected View initView(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.fragment_input_scan, container, false);

        initTitle(view);

        return view;
    }

    //初始化标题栏
    private void initTitle(View view) {
        new TitleBuilder(view)
                .setExternalTitleBgRes(R.drawable.bg_blue_icon)
                .setTitleText(getString(R.string.scan_online))
                .build();
    }

    @Override
    protected void initEvent() {
    }

    @Override
    protected void initData() {
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
//        Settings.System.putInt(getContext().getContentResolver(), "status_bar_disabled", 0);
        getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

}
